package com.probox.modules.controller.centre;

import com.probox.common.core.web.domain.AjaxResult;
import com.probox.common.entity.service.centre.ICustomerInfoService;
import com.probox.common.entity.vo.centre.customer.CustomerQueryVo;
import com.probox.common.entity.vo.centre.customer.CustomerRealVo;
import com.probox.common.entity.vo.centre.customer.MemberlVo;
import com.probox.common.entity.vo.centre.map.ProductAxisMap;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Kite
 * @date 2021/7/23
 */
@Api(value = "数据中心模块",tags = {"客户数据接口"})
@RestController
@RequestMapping("/centre-data/count/customer")
public class CentreCustomerController {

    @Autowired
    private ICustomerInfoService customerInfoService;

    /**
     *查询总客户 访客量  新增客户 成交客户
     *
     * @return
     */
    @ApiOperation(value = "查询总客户 访客量  新增客户 成交客户")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CustomerRealVo.class)})
    @GetMapping("getCustomerRealData")
    public AjaxResult getCustomerRealData(CustomerQueryVo customerQueryVo){
        CustomerRealVo customerRealVo = new CustomerRealVo();
        customerRealVo.setMakeCustomerTotal(customerInfoService.selectMakeClientTotal(customerQueryVo));
        //customerRealVo.setCustomerTotal(customerInfoService.selectCustomerTotal(customerQueryVo));
        customerRealVo.setNewlyCustomerTotal(customerInfoService.selectNewlyCustomer(customerQueryVo));
        customerRealVo.setVisitorsTotal(customerInfoService.selectVisitorsTotal(customerQueryVo));
        return AjaxResult.success(customerRealVo);
    }

    /**
     *查询某时间段新客户统计
     * @return
     */
    @ApiOperation(value = "查询某时间段新客户统计")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductAxisMap.class)})
    @GetMapping("getNewlyCustomerMap")
    public AjaxResult getNewlyCustomerMap(CustomerQueryVo customerQueryVo){
        return AjaxResult.success(  customerInfoService.selectNewlyCustomerMap(customerQueryVo));
    }


    /**
     *查询总会员 新增会员数  升级会员数 储值会员数
     *
     * @return
     */
    @ApiOperation(value = "查询总会员 新增会员数  升级会员数 储值会员数")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CustomerRealVo.class)})
    @GetMapping("getMemberData")
    public AjaxResult getMemberData(CustomerQueryVo customerQueryVo){
        MemberlVo memberData = customerInfoService.getMemberData(customerQueryVo);
        return AjaxResult.success(memberData);
    }

    /**
     *成交会员数 加购会员数  领券会员数 访问会员数
     *
     * @return
     */
    @ApiOperation(value = "成交会员数 加购会员数  收藏会员数 访问会员数")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CustomerRealVo.class)})
    @GetMapping("getMemberBehaviorData")
    public AjaxResult getMemberBehaviorData(CustomerQueryVo customerQueryVo){
        MemberlVo memberlVo = new MemberlVo();
        List list = customerInfoService.selectMemberIdList(customerQueryVo);
        customerQueryVo.setCustomerUid(list);
        if (list.size() != 0){
            memberlVo.setMembershipVisitNumber(customerInfoService.selectMemberVisitorsData(customerQueryVo));
            memberlVo.setMemberShoppingNumber(customerInfoService.selectMemberAddCarData(customerQueryVo));
            memberlVo.setMemberMakeNumber(customerInfoService.selectMakeMemberTotal(customerQueryVo));
            memberlVo.setMembershipCollectNumber(customerInfoService.selectMembershipCollectNumber(customerQueryVo));
        }else{
            memberlVo.setMembershipVisitNumber(0);
            memberlVo.setMemberShoppingNumber(0);
            memberlVo.setMemberMakeNumber(0);
            memberlVo.setMembershipCollectNumber(0);
        }

        return AjaxResult.success(memberlVo);
    }

    /**
     *查询近三十天数据统计
     *
     * @return
     */
    @ApiOperation(value = "查询近三十天数据统计")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CustomerRealVo.class)})
    @GetMapping("getMemberTotalMap")
    public AjaxResult getMemberTotalMap(CustomerQueryVo customerQueryVo){
        return AjaxResult.success(customerInfoService.getMemberTotalMap(customerQueryVo));
    }


}
